//
//  TestTrip.swift
//  ImGuider X
//
//  Created by 陆涛 on 2018/10/15.
//  Copyright © 2018 imguider. All rights reserved.
//

import UIKit
import CoreLocation

/// 行程类型
///
/// - other: 其他
/// - flight: 航班
/// - hotel: 酒店
/// - scenic: 景点
/// - restaurant: 餐饮
/// - shopping: 购物
/// - activity: 活动
enum PlanType1:Int,Codable {
    
    case flight = 1
    case hotel = 2
    case scenic = 3
    case restaurant = 4
    case shopping = 5
    case activity = 6
    case other = 7
    case line = 8
}

class Record1: NSObject, Codable {
    
    var id,spotname,ename,playpath,spotpictures,keywords,lat,lng,nodenumber:String?
    var number,transport:Int?
    
    var pictureArray:[String]? {
        
        return spotpictures?.components(separatedBy: ",").compactMap({ str -> String? in
            
            return str.count > 0 ? str : nil
        })
    }
    
    var coor:CLLocationCoordinate2D? {
        
        guard let lat = lat, let lat1 = Double(lat),let lng = lng, let lng1 = Double(lng) else {
            
            return nil
        }
        
        let coor = CLLocationCoordinate2D(latitude: lat1, longitude: lng1)
        
        if CLLocationCoordinate2DIsValid(coor) {
            
            return coor
        }
        
        return nil
    }
}


class Guide1: NSObject, Codable {
    
    var guideid,headimg,realname,certificate,introduction:String?
    var favourcount,viewcount,visitcount:Int?
}

class Line1: NSObject,Codable {
    
    var viewName,cityName,city,country:String?
    var lineid,unionid,pictures,playpath,linename,linedesc,price,timelabel,audiopic,labels:String?
    var recordcount,transport,visits:Int?
    var bought:Bool = false// 是否购买
    var hascode:Bool = false// 是否有官方编号
    var guide:Guide1?
    var records:[Record1]?
    
    var pictureArray:[String]? {
        
        return pictures?.components(separatedBy: ",").compactMap({ str -> String? in
            
            return str.count > 0 ? str : nil
        })
    }
}

class Scenic1: NSObject,Codable {
    
    var ralationId:String?
    
    var id,viewname,ename,website,openinfo,telephone,address,pictures:String?
    var lat,lng:Double?
    var hasmap,inroom,visit,guides,rank:Int?
    var lines: [Line1]?
    
    var pictureArray:[String]? {
        
        return pictures?.components(separatedBy: ",").compactMap({ str -> String? in
            
            return str.count > 0 ? str : nil
        })
    }
    
    var coor:CLLocationCoordinate2D? {
        
        guard let lat = lat, let lng = lng else {
            
            return nil
        }
        
        let coor = CLLocationCoordinate2D(latitude: lat, longitude: lng)
        
        if CLLocationCoordinate2DIsValid(coor) {
            
            return coor
        }
        
        return nil
    }
}


class Promotion1: NSObject,Codable {
    
    var discountNum,name,detail,type,url,useTip,remarks:String?
    var moneyType,freeNum:String?
}

class Airplane1: NSObject,Codable {
    
    
}

class Calendar1: NSObject,Codable {
    
    var id:String?
    var planType:PlanType1?
    var planTime,intro,address,title,etitle,telephone,website:String?
    var pictures,opentime,tags,consumption:String?
    var daty,night:Int?
    var lat,lng:Double?
    
    var viewDetail:Scenic1?

//    var lineDetail:Line1?
    
    var airplaneDetail:AirplaneDetailModel?
    var promotion:[Promotion1]?
    
    var pictureArray:[String]? {
        
        return pictures?.components(separatedBy: ",").compactMap({ str -> String? in
            
            return str.count > 0 ? str : nil
        })
    }
    
    var tagArray:[String]? {
        
        return tags?.components(separatedBy: ",").compactMap({ str -> String? in
            
            return str.count > 0 ? str : nil
        })
    }
    
    var coor:CLLocationCoordinate2D? {
        
        guard let lat = lat,let lng = lng else {
            
            return nil
        }
        
        let coor = CLLocationCoordinate2D(latitude: lat, longitude: lng)
        
        if CLLocationCoordinate2DIsValid(coor) {
            
            return coor
        }
        
        return nil
    }
}

class Day1: NSObject,Codable {
    
    var date: String?
    var calendars: [Calendar1]?
    var hotel: Calendar1?
    var dayofweek: Int?
    var day:Int?

}

class City1: NSObject,Codable {
    
    var cityName,pic:String?
    var destinationDate:String?
    var stay:Int?
    
    var hotels:[Calendar1]?
    var days:[Day1]?
}

class TestTrip: NSObject,Codable {
    
    var orderId:String?
    var maps,pictures:String?
    var returnDate,departureDate:String?
    var planName,tags,createTime,intro,days:String?
    
    var cities:[City1]?
    
    
    
}

